package com.stockz.equity.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

@Entity
@NamedQueries({
@NamedQuery(name=Scrip.GetAllScripQuery, query="select s from Scrip s"),
@NamedQuery(name=Scrip.GetAllScripForDateQuery, query="select s from Scrip s,Bar b where b.scripCode = s.scripCode and b.date = ?")
})
@Table(name="SCRIP")
public class Scrip implements Serializable, Cloneable {
	private static final long serialVersionUID = 3433324982001068494L;
	
	public static final String GetAllScripQuery = "GetAllScripQuery";
	public static final String GetAllScripForDateQuery = "GetAllScripForDateQuery";
	
	@Id
	@Column(name="CODE")
	private String scripCode;
	@Column(name="SCRIPID")
	private String scripId;
	@Column(name="NAME")
	private String scripName;
	
	@Column
	private String industryCode;
	@Column
	private String sectorCode;
	@Column
	private String exchangeCode;
	
	public Scrip() {
		// TODO Auto-generated constructor stub
	}
	
	
	
	public Scrip(String scripCode, String scripName) {
		super();
		this.scripCode = scripCode;
		this.scripName = scripName;
	}



	@Override
	public boolean equals(Object obj) {
		if(obj == null || !(obj instanceof Scrip)){
			return false;
		}
		return ((Scrip)obj).getScripCode().equalsIgnoreCase(getScripCode());
	}
	
	@Override
	public int hashCode() {
		return getScripCode().hashCode();
	}
	
	@Override
	public String toString() {
		return scripName;
	}
	
	public String getScripCode() {
		return scripCode;
	}
	public void setScripCode(String scripCode) {
		this.scripCode = scripCode;
	}
	public String getScripId() {
		return scripId;
	}
	public void setScripId(String scripId) {
		this.scripId = scripId;
	}
	public String getScripName() {
		return scripName;
	}
	public void setScripName(String scripName) {
		this.scripName = scripName;
	}

	public String getIndustryCode() {
		return industryCode;
	}

	public void setIndustryCode(String industryCode) {
		this.industryCode = industryCode;
	}

	public String getSectorCode() {
		return sectorCode;
	}

	public void setSectorCode(String sectorCode) {
		this.sectorCode = sectorCode;
	}

	public String getExchangeCode() {
		return exchangeCode;
	}

	public void setExchangeCode(String exchangeCode) {
		this.exchangeCode = exchangeCode;
	}
}
